package com.lyan.myapplication

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.Toast

 class MainActivity : BaseActivity() {

    external fun sayHello(a: Int, b: Int): String

     private var  editText1:EditText? = null
     private var editText2:EditText? = null
     private var button:Button? = null
     private var button2:Button? = null

    override fun getContentView(): Int {
        return R.layout.activity_main
    }

    override fun init(savedInstanceState: Bundle?) {
        setTitle("首页")
        setTopLeftButton(0, object : OnClickListener {
            override fun onClick() {
                Toast.makeText(this@MainActivity, "点击了返回", Toast.LENGTH_SHORT).show()
            }

        })
        setTopRightButton(R.mipmap.ic_launcher, "",object :OnClickListener{
            override fun onClick() {
                Toast.makeText(this@MainActivity, "点击了右上角菜单", Toast.LENGTH_SHORT).show()
            }
        })
        editText1 = findViewById(R.id.editText) as EditText
        editText2 = findViewById(R.id.editText2) as EditText
        button = findViewById(R.id.button) as Button
        button?.setOnClickListener { Log.d(TAG,"登录") }

        button2 = findViewById(R.id.button2) as Button
        button2?.setOnClickListener {
            val intent = Intent(this@MainActivity, MyReactActivity::class.java)
            this@MainActivity.startActivity(intent)
        }

        val quantity = 5
        val price:Double  = 20.3
        val name:String = "大米"
        Log.d(TAG,"单价:$price")
        println("数量:$quantity");
        println("产品:$name 总价:${quantity*price}")



    }



     companion object {

        private val TAG = "test"

        init {
            System.loadLibrary("hello")
        }
    }



}
